﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TractRecord.Process
{
    public partial class Verify : TractRecordBasePage 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string sKey = Request.QueryString["key"];

                Guid key = new Guid(sKey);

                MembershipUser user = Membership.GetUser(key);

                user.IsApproved = true;

                Membership.UpdateUser(user);

                Session["approved"] = true;

                Code.Common.Log("Activated user: " + user.UserName, "Audit");

                Response.Redirect("/Default.aspx");
            }
            catch (Exception ex)
            {
                Response.Write("Failed to activate user.");

                Code.Common.Log(ex.ToString(), "Verify.Page_Load", 100, 0, System.Diagnostics.TraceEventType.Error, "Verify.Page_Load");
            }
        }
    }
}